#include "StdAfx.h"
#include "DCDeviceContext.h"

CDCDeviceContext::CDCDeviceContext(CDC* pDC):m_pDC(pDC)
{
}

CDCDeviceContext::~CDCDeviceContext()
{
	//if (m_pDC)
	//{
	//	m_pDC->GetWindow()->ReleaseDC(m_pDC);
	//	delete m_pDC;
	//}
}

void CDCDeviceContext::invalidate()
{
	m_pDC->GetWindow()->Invalidate();
}

void CDCDeviceContext::drawPoint(double x, double y)
{
	
}

void CDCDeviceContext::line(double x1,double y1,double x2,double y2)
{
	m_pDC->MoveTo(x1,y1);
	m_pDC->LineTo(x2,y2);
}

void CDCDeviceContext::ellipse(double x1,double y1,double x2,double y2)
{
	m_pDC->Ellipse(x1,y1,x2,y2);
}

void CDCDeviceContext::setDrawProperties(CMapLayerDrawProperties drawProperties)
{
    m_drawProperties = drawProperties;
    //CPen pen(PS_SOLID,m_drawProperties.m_width, RGB(0,255,0));
    m_pCurPen = new CPen(PS_SOLID,m_drawProperties.m_width, RGB(m_drawProperties.m_rColor,m_drawProperties.m_gColor,m_drawProperties.m_bColor));
    //pen.CreatePen(PS_SOLID,m_drawProperties.m_width, RGB(255,0,0));
    m_pOldPen = m_pDC->SelectObject(m_pCurPen);
}

void CDCDeviceContext::restore()
{
    m_pDC->SelectObject(m_pOldPen);
    if (m_pCurPen)
    {
        delete m_pCurPen;
    }
}
